<template>
<!--  <h2>检查项信息</h2>-->
  <div>
    <div class="checkScrol">
      <table class="datatable">
        <thead>
        <tr>
          <th>选择</th>
          <th>项目编码</th>
          <th>项目名称</th>
          <th>项目说明</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="c in tableData">
          <td>
            <input :id="c.id" v-model="checkitemIds" type="checkbox" :value="c.id">
          </td>
          <td><label :for="c.id">{{c.code}}</label></td>
          <td><label :for="c.id">{{c.name}}</label></td>
          <td><label :for="c.id">{{c.remark}}</label></td>
        </tr>
        </tbody>
      </table>
    </div>

  </div>
</template>

<script>
export default {
  name: "ProjectInfo",
  data(){
    return {
      tableData:[],
      checkitemIds:[],
      headers:this.$cookies.get("token") != null ? this.$cookies.get("token") : '',
    }
  },
  beforeMount() {
    this.$axios.get(`/api/checkitem/getAll.do`,{
      headers:this.headers
    }).then((res)=>{
      if(!res.data.flag){
        this.$message.error("查询检查项信息失败")
      }else{
        this.tableData = res.data.data
      }
    })
  },
  mounted() {
    this.$bus.$on("clear",(data)=>{
      // console.log(data)
      this.checkitemIds = []
      // console.log(this.checkitemIds)
    })
    this.$bus.$on("edit_id",(data)=>{
      this.$axios.get(`/api/checkgroup/getProjectInfo.do?id=${data}`,{
        headers:this.headers
      }).then((res)=>{
        if(!res.data.flag){
          this.$message.error("查询检查项信息出错啦")
        }else{
          this.checkitemIds = res.data.data
          this.$store.dispatch("setIds",this.checkitemIds)
        }
      })
    })

  },
  updated() {
    // console.log(this.checkitemIds)
    this.$store.dispatch("setIds",this.checkitemIds)
  }
}
</script>

<style scoped>
.datatable {
  position: relative;
  box-sizing: border-box;
  -webkit-box-flex: 1;
  width: 100%;
  max-width: 100%;
  font-size: 14px;
  color: rgb(96, 98, 102);
  overflow: hidden;
  flex: 1 1 0%;
}
.datatable td, .datatable th {
  padding: 12px 0;
  min-width: 0;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  text-overflow: ellipsis;
  vertical-align: middle;
  position: relative;
  text-align: left;
}
</style>